job_type_by_year <-
  analysis_df %>%
  filter(!is.na(occ_recode)) %>%
  group_by(YEAR, occ_recode) %>%
  summarise(val = n()) %>%
  group_by(YEAR) %>%
  mutate(tot = sum(val)) %>%
  mutate(prop = val/tot) %>%
  mutate(occ_label = case_when(occ_recode == "blue_collar" ~ "Blue collar",
                               occ_recode == "white_collar" ~ "White collar",
                               occ_recode == "fireman" ~ "Fire dept",
                               occ_recode == "police" ~ "Police dept",
                               occ_recode == "teacher" ~ "Teacher"),
         occ_label = factor(occ_label, levels = c("Blue collar", "White collar", "Teacher", "Police dept", "Fire dept"))) %>%
  ggplot(aes(x=YEAR, y = prop*100, group = occ_label, shape = occ_label, color = occ_label, linetype = occ_label)) +
  geom_point() +
  geom_line() +
  scale_color_grey() +
  theme_bw() +
  theme(panel.grid.minor = element_blank(), 
        panel.grid.major.x = element_blank(),
        axis.line.y.left = element_blank(),
        legend.position = "right",
        strip.background = element_blank(),
        legend.title = element_blank(),
        axis.title.x = element_blank(),
        axis.line = element_line(colour = "black"),
        panel.border = element_blank()) +
  theme(text=element_text(size=9)) +
  scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920, 1930, 1940)) +
  ylab("Propotion of Local Government Jobs (%)")

#ggsave('../Apps/Overleaf/merit paper/outputs/job_type_by_year.png', plot = job_type_by_year, width=6, height=3)
ggsave('./replication_file/_5_outputs/figures/figure_a3.png', plot = job_type_by_year, width=6, height=3)
